#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
bool flag1 = true, flag2 = true;
int divit[100005], speed[100005], acres[100005], Tester[100005], testmap[1000005], T;
void init(){
	//memset(divit, divit + maxn,0);
	//memset(speed, speed + maxn,0);
	//memset(acres, acres + maxn,0);
	//memset(Tester, Tester + maxn,0);
	//memset(testmap, testmap + 100005,0);
	for(int i = 1; i <= maxn; ++i)
	{
		divit[i] = 0;
		speed[i] = 0;
		acres[i] = 0;
		Tester[i] = 0;
		testmap[i] = 0;
	}
	flag1 = true;
	flag2 = true;

}
void solve(int n, int m, int l, int v)
{
	int punishs = 0,havepu = 0;
	if(flag1 == true || flag1 == false)
	{
		for(int i = 1; i <= n; ++i)
		{
			int s = l - divit[i];
			double ensp = sqrt(1.0000000 * speed[i] * speed[i] + 2.00000 * acres[i] * s), out_s;
			if(acres[i] != 0)
				out_s = (1.0000000 * v * v - 1.000000*speed[i] * speed[i]) * 0.500000 / acres[i];
			else
				out_s = l - divit[i];

			double out_ss = divit[i] + out_s;
			//cout << "car" << i <<endl;
			if(ensp <= v)
				continue;
			for(int j = divit[i]; j <= l; ++j)
			{
				//if(T == 3)
					//cout<< "test";
				if(testmap[j] == 1)
				{
					//if(T == 3)
						//cout <<  "test";
					if(acres[i] == 0)
					{
						punishs ++;
						havepu = 1;
						break;
					}else{
						double vpre = sqrt(1.00000*speed[i] * speed[i] + 2.00000000 * acres[i] * j);
						//if(T == 3)
							//cout << vpre << endl;
						if(vpre > v)
						{
							//if(T == 3)
								//cout << "a>0 punish"<<endl;
							punishs ++;
							havepu = 1;
							break;
						}
					}
				}

			}
		}
		cout << punishs << " " << (havepu == 1 ? m - 1 : m )<< endl;
	}
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin >> T;
	init();
	for(int i = 1; i <= T; ++i)
	{
		int n, m, l, v;
		cin >> n >> m >> l >> v;
		for(int j = 1; j <= n; ++j){
			cin >> divit[j] >> speed[j] >> acres[j];
			if(acres[j] != 0)
				flag1 = false;
			if(acres[j] < 0)
				flag2 = false;
		}
		for(int k = 1; k <= m; ++k)
		{
			cin >> Tester[k];
			testmap[Tester[k]] = 1;
		}
		solve(n, m, l, v);
		init();
	}
	
	return 0;
}